package com.example.demo.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Vehicle;
import com.example.demo.mapper.VehicleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VehicleService extends ServiceImpl<VehicleMapper, Vehicle> {

    VehicleMapper vehicleMapper;
    @Autowired
    VehicleService(VehicleMapper mapper){
        this.vehicleMapper=mapper;
    }

    public List<Vehicle> getAll(){
        return vehicleMapper.getAll();
    }

    public Vehicle getById(Long id) {
        return vehicleMapper.getById(id);
    }

    public boolean insert(Vehicle entity){
        return vehicleMapper.insert(entity) > 0;
    }

    public boolean update(Vehicle entity){
        return vehicleMapper.update(entity) > 0;
    }
    public boolean delete(Long id) {
        int result=vehicleMapper.deleteById(id);
        return result > 0;
    }
}
